import { _decorator, Component, instantiate, Label, Node, tween } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('DragTetrisTipScorePanel')
export default class DragTetris_TipScorePanel extends Component {
    static Instance: DragTetris_TipScorePanel;
    @property(Node)
    parent: Node | null = null;
    @property(Node)
    Prefab: Node | null = null;
    array: Node[] = new Array();
    onLoad() {
        DragTetris_TipScorePanel.Instance = this;
    }
    start() { }
    Show(content: string, duration = 0.4) {
        // const node: Node = instantiate(this.Prefab);
        // let label = node.getComponentInChildren(Label);
        // if (!label) {
        //     label = node.addComponent(Label);
        // }

        // this.DestroyAll();
        // this.array.push(node);

        // label.string = content;
        // node.parent = this.parent;
        // node.setPosition(0, 0);
        // node.active = true;
        // node.scale = 0.2;
        // node.opacity = 0;

        // tween(node)
        //     .to(0.3, { scale: 1.4, opacity: 255 }, { easing: "" })
        //     .to(0.2, { scale: 1 }, { easing: "" })
        //     .to(0.2, { scale: 1.1 }, { easing: "" })
        //     .to(0.2, { scale: 1 }, { easing: "" })
        //     .to(0.2, { scale: 1.1 }, { easing: "" })
        //     .to(0.2, { scale: 1 }, { easing: "" })

        //     .delay(duration)
        //     .to(0.2, { opacity: 0 }, { easing: "" })
        //     .call(() => {
        //         this.DestroyAll();
        //     })
        //     .start();
    }
    DestroyAll() {
        this.array.forEach((element) => {
            element.destroy();
        });
        this.array = new Array();
    }
}

// /** 调试 */
window["DragTetris_TipScorePanel"] = DragTetris_TipScorePanel;